<template>
  <div class="comment_login">
    <input
      type="text"
      v-model="LoginuserEmail"
      placeholder="请输入用户名/手机号/邮箱"
    />
    <input type="password" v-model="LoginuserPwd" placeholder="请输入密码" />
    <div class="comment_forget">
      <a href="javascript:;">忘记密码?</a>
    </div>

    <div class="login_btn">
      <a href="javascript:;" @click="doLogin()"> 登录</a>
    </div>
    <div class="login_bottom">
      您可以用手机直接访问 &nbsp;&nbsp;<a>m.sn.cn</a>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      LoginuserEmail: "",
      LoginuserPwd: "",
    };
  },
  methods: {
    doLogin() {
      if (!this.LoginuserEmail.trim() && !this.LoginuserPwd.trim()) {
        return;
      }
      // console.log(this.userEmail,this.userPwd)
      let params = `email=${this.LoginuserEmail}&pwd=${this.LoginuserPwd}`;
          if (timer == null) {
            // 注册操作
            console.log('注册操作');
            this.axios.post("/user/login", params).then((res) => {
              // console.log(res)
              if (res.data.code == 200) {
                // 登陆成功
                // console.log(res)
                localStorage.setItem("token", res.data.token);
                localStorage.setItem("userName", this.LoginuserEmail);
                // console.log('登陆成功')
                location.reload();

                // this.$router.go(0)
              } else {
                alert(res.data.msg);
              }
            });
            timer = setTimeout(() => {
              timer = null;
              console.log('结束');
            }, 1000);
          }
    },
  },
};
</script>
<style src="../assets/css/commentlogin.css" scoped></style>
<style lang="scss" scoped></style>
